Adding Users with a Web Component

Description

Step by step instructions for adding users to a web component.

This topic is obsolete for V11 and above. In V11 when you create a new Dialog component, you can choose from list of pre-defined Dialogs. Select the 'SecurityFramework-CreateNewUserAccount' entry in the list. See video D_SF_1 for more details.

This example shows how to create a dialog component that will accept all the information required to add a new user to the web user table.

images/WPT_New_User_Dialog.gif

The controls on the dialog must have names that match fields currently being used by the web security settings. The actual fields being used will be different depending on the security options selected.

Getting the Current Field Names

  1. In the Database Control Panel click Interactive Window to open the Interactive Window.

  2. In the Interactive Window, enter the following code and click Enter.

    ?a5ws_user_file_field_list()
    = Guid
    Password
    RedirPage
    Ulink
    Userid
  3. This shows the field names currently available in the web users table.

  4. There are two additional fields that can be used

    • 1. "groups" - This field can be used to select security groups for the user.

    • 2. "confirm_password" - This field can be added to require entering a password a second time to validate the value.

Creating the Dialog

  1. In the Web Projects Control Panel click New > Web Component > Next > Dialog > OK.

  2. Select Save, name the dialog component "NewUser", and click Save.

  3. Display the Form > Controls menu.

  4. Add six controls. NOTE: If you are using password encryption, the max length for the password field must be at least 60 to allow space for the encypted value.

    images/atable.png
  5. Select "RedirPage" in the Selected Controls list.

    • 1. Click '...' in DropDownBox Properties > Choices to display the Define Choices dialog.

    • 2. Set Define Choices > List Type to "Dynamic".

    • 3. Set Data Source > Data source type to "Variable".

    • 4. Set Data Source > Variable name to "PageList".

    • 5. Click OK to continue.

  6. Select "Groups" in the Selected Controls list.

    • 1. Click '...' in Checkbox Properties > Choices to display the Define Choices dialog.

    • 2. Set Define Choices > List Type to "Dynamic".

    • 3. Set Data Source > Data source type to "Variable".

    • 4. Set Data Source > Variable name to "GroupList".

    • 5. Click OK to continue.

  7. Display the Form > Properties menu.

  8. Click the '...' in Server Events > Initialize to display the Form Events dialog. Enter the following code and click OK.

    a5ws_get_webuser_values(CurrentForm)
  9. Click the '...' button in Server Events > Validate to display the Form Events dialog. Enter the following code and click OK.

    a5ws_save_webuser_values(CurrentForm)
  10. Click '...' in Server Events > After Validate to display the Form Events dialog. Enter the following code and click OK. Note: If a new record was created in the Validate event, the new security record guid value will be returned in the variable CurrentForm.Controls.Guid.Value. This MUST be passed back to the function a5ws_get_webuser_values() to find the new record to reload the saved values.

    Dim UserValue as p 
    UserValue.guid = alltrim(CurrentForm.Controls.Guid.Value) 
    a5ws_get_webuser_values(CurrentForm,UserValue)
  11. Click '...' in Server Events > Activate to display the Form Events dialog. Enter the following code and click OK.

    pagelist = a5ws_get_page_list(request)
    grouplist = a5ws_get_groups(request,.T.)
  12. Note: If you want to allow the user to leave the redirect page blank, you can modify the Activate code as follows:

    pagelist = ""+crlf()+a5ws_get_page_list(request)
  13. Click Save and Close.

Creating the Page

  1. In the Web Projects Control Panel click New > A5W Page > OK.

  2. Select Save, name the page "NewUser", and click Save.

  3. Click Insert Component > Select.

  4. Select the "NewUser" component and click OK > OK.

  5. Close the HTML Editor and return to the Web Projects Control Panel.

  6. Click Web Security > Page Security > OK.

  7. Move NewUser.A5W to the Always Allowed column and click OK.

Adding a New User

  1. In the Web Projects Control Panel click Publish.

  2. Select All files in project.

  3. Clear Publish new or modified files only.

  4. Click Clear Publishing History.

  5. Select Launch browser after files are published.

  6. In the Page to show list select "NewUser.a5w".

  7. Click Publish.

  8. When the NewUser page appears in your browser:

    • 1. Enter "ellen" into User ID.

    • 2. Enter "ellen" into Password.

    • 3. Enter "ellen" into Confirm Password.

    • 4. Select "Menu.a5w" in Redirect Page.

    • 5. Select "Accounting" in Permissions.

  9. Click Submit.

    images/WPT_Add_New_User_via_Web.gif

Limitations

Web publishing applications only.

See Also